package com.nineclock.system.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.system.SmsControllerApi;
import com.nineclock.system.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com
 * @Version 1.0
 */
@RestController
@RequestMapping("/sms")
public class SmsController implements SmsControllerApi {

    @Autowired
    SmsService smsService;

    @Override
    @GetMapping("/code")
    public Result createSmsCode(String mobile, String type) {
        smsService.sendCode(mobile, type);
        return Result.success();
    }

    @Override
    @GetMapping("/verify")
    public Result verify(String mobile, String type, String checkcode) {
        Boolean flag = smsService.verify(mobile, type, checkcode);
        return Result.success(flag);
    }

}
